<?php

class ThemeBasic extends Theme {

    private $mPageTopUrl;
    private $mPageBottomUrl;
    private $mPageContainer;
    private $mInformation;
    private $mNews;
    private $mNotification;


    public function SetNotification($pNews) {
        if (is_array($pNews)) {
            $this->mNews = $pNews;
        }
    }

    public function GetNotification() {
        $tNotification = '<p>asdsdadsa</p><p>asdasdqwewqe</p><p>rettretre</p><p>zxczxcx</p>';
        return $tNotification;
    }

    public function GetUserInfo() {
        $tOutput = "<span><b>" . $this->GetInfoUserName() . "</b>, </span><span>" . $this->GetInfoUserLevel() . "</span>";
        return $tOutput;
    }

    public function GetNews() {
        $tFieldSupport="";
        $tNews = "<div id=\"newsticker-jcarousellite\">\n" .
                "\t<ul style=\"padding:0px 0px;\">\n";
        if (!empty($this->mNews)) {
            //$tNews.= "\t<li style=\"padding:0px\"><div>Anda memiliki " . count($this->mNews) . " notifikasi</div></li>\n";
            foreach ($this->mNews as $tId=>$tRes) {
                $tNews.= "\t<li style=\"padding:0px; padding-left:10px\">\n";
                $tNews.= "\t\t<div class=\"$tId\">$tRes</div>\n";
                $tNews.= "\t\t<div class=\"clear\">&nbsp;</div>\n" .
                        "\t</li>";
                
                $tFieldSupport.= "<div id=\"$tId\" class=\"FieldSupport\"></div>";
            }
        } else {
            $tNews.= "\t<li style=\"padding:0px\"><div>--</div<</li>\n";
        }
        $tNews.= "\t</ul>\n";
        
        return $tFieldSupport.$tNews;
    }

    public function GetInformation() {
        return $this->mInformation;
    }

    public function GetPageTop() {
        return $this->mPageTopUrl;
    }

    public function GetPageBottom() {
        return $this->mPageBottomUrl;
    }

    public function GetHeaderContainer() {
        $tPage ="<div id=\"Header\"> \n" .
                "\t<div id=\"Header-Container\"> \n" .
                "\t\t<div id=\"information-Container\">\n" .
                "\t\t\t" . $this->GetInformation() .
                "\t\t</div>\n\n" .
                
                "\t\t<div id=\"Menu\">\n" .
                "\t\t\t<div id=\"Menu-List\">\n" .
                "\t\t\t" . $this->GetMenu() .
                "\t\t\t</div>\n" . 
                "\t\t\t<div id=\"Menu-Button\"><img src=\"" . THEME_IMAGES_PATH . "header-menu-button.png\" /></div>\n" .
                "\t\t\t<div style=\" margin-left:120px\" class=\"Header-ButtonHover\"><img src=\"" . THEME_IMAGES_PATH . "header-button_hover.png\" /></div>\n" .
                "\t\t</div> \n" .
                
                "\t<div id=\"Notification\">\n" .
                "\t\t<div id=\"Notification-Container\">\n" .
                "\t\t" . $this->GetNotification() .
                "\t\t</div>\n" .
                "\t\t<div id=\"Notification-Button\">\n" .
                "\t\t\t<ul id=\"Notification-Highlight\">\n" .
                "\t\t\t\t<li class=\"Notification\" id=\"UserInfo\">" . $this->GetUserInfo() . "</li>\n" .
                "\t\t\t\t<li class=\"Notification\">" . $this->GetNews() . "</li>\n" .
                "\t\t\t</ul>" .
                "\t\t</div>\n" .
                "\t\t<div style=\" margin-left:340px\" class=\"Header-ButtonHover\"><img src=\"" . THEME_IMAGES_PATH . "header-button_hover.png\" /></div>\n" .
                "\t</div> \n" .
                
                "\t<div id=\"banner\">\n" .
                "\t\t<img src=\"" . THEME_IMAGES_PATH . "header-banner.png\" />\n" .
                "\t\t<div id=\"version\">" . APPLICATION_VERSION . " <br/>" . APPLICATION_LAST_UPDATE . "</div>\n" .
                "\t</div> \n" .
                "\t<ul id=\"Shortcut\">\n" .
                "\t\t<li><a href=\"main.php\" class=\"Shortcut-Button\"><img src=\"" . THEME_IMAGES_PATH . "shortcut-home.png\" /></a></li>\n" .
                "\t\t<li><a href=\"main.php?menu=99&submenu=311\" class=\"Shortcut-Button\"><img src=\"" . THEME_IMAGES_PATH . "shortcut-akun.png\" /></a></li>\n" .
                "\t\t<li><a href=\"main.php\" class=\"Shortcut-Button\"><img src=\"" . THEME_IMAGES_PATH . "shortcut-help.png\" /></a></li>\n" .
                "\t\t<li><a href=\"logout.php\" class=\"Shortcut-Button\"><img src=\"" . THEME_IMAGES_PATH . "shortcut-logout.png\" /></a></li>\n" .
                "\t</ul> \n" .
                "</div>\n" .
                "</div>\n";
        return $tPage;
    }

    public function GetPageContainer(&$_ERRHANDLER) {
        echo "\n<div id=\"Page\"> \n" .
        "<div id=\"Page-Container\"> \n" .
        "\t<div id=\"Page-top\">\n" .
        "\t\t<div>\n" .
        "\t\t" . $this->GetPageTop() . "\n" . 
        "\t\t</div>\n" .
        "\t</div>\n\n" ;
        
        echo "\t<div id=\"Page-main\">\n";
        include_once($this->GetPage());
        echo "\t</div>\n\n" ;
        
        echo "\t<div id=\"Page-bottom\">\n" .
        "\t\t" . $this->GetPageBottom() . "\n".
        "\t</div>\n" .
        "</div>\n" .
        "</div>\n";
    }

    public function GetGraphicPageContainer(&$_ERRHANDLER) {
        echo "<div id=\"Page\"> \n" .
        "<div id=\"Page-Container\"> \n" .
        "\t<div id=\"Page-main\">\n".
        "<div>SiLECT</div>\n".
        "<hr />\n";
        
        include_once($this->GetPage());
        echo "\t</div>\n\n" .
        "\t<div id=\"Page-bottom\">\n" .
        "\t\t" . $this->GetPageTop() .
        "\t</div>\n" .
        "</div>\n" .
        "</div>\n";
    }

    public function GetFooterContainer() {
        $tPage ="\n<div id=\"Footer\"> \n" .
                "\t<div id=\"Footer-Container\"> \n" .
                "\t\t" . $this->GetFooter() . "\n" .
                "\t</div>\n" .
                "</div>\n";
        return $tPage;
    }

    /* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== */


    /* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== */
    /*  L O G I N  */

    public function GetLoginContainer() {
        $tPage =
                "<div id=\"Login-ShadowTop\"></div> \n" .
                "<div id=\"Login-ShadowBottom\"></div> \n" .
                "<div id=\"Login\"> \n" .
                "<div id=\"Login-Container\"> \n" .
                "\t<div id=\"Logo-Container\">\n" .
                "\t<ul>\n" .
                "\t\t<li>\n" .
                "\t\t\t<div>\n" .
                "\t\t\t<img src=\"" . THEME_IMAGES_PATH . "index-logo-institusi.png\">\n" .
                "\t\t\t</div>" .
                "\t\t\t<div id=\"Login-Application\">" . $this->GetFooter() . "</div>\n" .
                "\t\t\t</li>\n" .
                "\t\t<li class=\"border\">" . $this->GetPage() . "</li>\n" .
                "\t\t<li>\n" .
                "\t\t\t<div id=\"Login-Button\">\n" .
                "\t\t\t<div><img src=\"" . THEME_IMAGES_PATH . "index-logo-sika_glow.png\"></div>\n" .
                "\t\t\t</div>\n" .
                "\t\t\t<div id=\"Login-Form\">\n" .
                "\t\t\t<h1>LOGIN</h1>\n" .
                "\t\t\t<form action=\"login.php\" method=\"post\">" .
                "\t\t\t<table border=\"0\">" .
                "\t\t\t\t<tr><td colspan=\"2\" align=\"center\" valign=\"top\"><img src=\"" . THEME_IMAGES_PATH . THEME_APPLICATION_LOGO . "\" height=\"165px\" /></td></tr>" .
                "\t\t\t\t<tr><td width=\"35%\">Username</td><td align=\"center\"><input type=\"text\" name=\"username\" /></td></tr>" .
                "\t\t\t\t<tr><td>Password</td><td align=\"center\"><input type=\"password\" name=\"password\" /></td></tr>" .
                "\t\t\t\t<tr><td></td><td align=\"center\"><input type=\"submit\" class=\"button\" value=\"Login\" /></td></tr>" .
                "\t\t\t</table>" .
                "\t\t\t</form>" .
                "\t\t\t</div>" .
                "\t\t</li>\n" .
                "\t</ul>\n" .
                "\t</div>\n\n" .
                "</div>\n" .
                "</div>\n";
        // <?php if(isset($_GET['err'])) echo '<tr><td colspan="2" style="color:red;"><b><i>Login attemp failed!</i></b></td></tr>';	

        return $tPage;
    }

    public function GetActivationContainer() {
        $tPage =
                "<div id=\"Activation-ShadowTop\"></div> \n" .
                "<div id=\"Activation-ShadowBottom\"></div> \n" .
                "<div id=\"Activation\"> \n" .
                "<div id=\"Activation-Container\"> \n" .
                "<div id=\"Logo-Container\"> <img src=\"" . THEME_IMAGES_PATH . THEME_APPLICATION_LOGO."\" height=\"165px\" /> </div> \n" . 
                "\t\t\t<h1>AKTIFASI AKUN</h1>\n" .
                "\t\t\t<p>Akun anda belum aktif sehingga anda tidak memiliki hak akses untuk mengakses sistem. Aktifkan akun anda dengan cara melakukan perubahan password melalui form di bawah ini.</p>\n" ;
        $tPage.= "<div id=\"Activation-Form\"> \n" .$this->GenerateActivationForm()."</div>";    
        
        $tPage.="</div> \n" .
                "</div> \n";
        // <?php if(isset($_GET['err'])) echo '<tr><td colspan="2" style="color:red;"><b><i>Login attemp failed!</i></b></td></tr>';	

        return $tPage;
    }

    public function GenerateActivationForm() {
        //SETUP FORM
        $tOutput= 
                "\t\t\t<fieldset>" .
                "\t\t\t<form name=\"formAkunActivation\" action=\"activating.php\" method=\"post\" onsubmit=\"return ValSubmitAkunActivation()\">" .
                "\t\t\t<table border=\"0\" align=\"center\">" .
                "\t\t\t\t<tr><td width=\"35%\">Password</td><td align=\"center\"><input type=\"password\" name=\"fPassword\" id=\"fPassword\" rel=\"required\" /></td></tr>" .
                "\t\t\t\t<tr><td>Ketik Ulang Password</td><td align=\"center\"><input type=\"password\" name=\"fRePassword\" id=\"fRePassword\" rel=\"required\" /></td></tr>" .
                "\t\t\t\t<tr><td></td><td align=\"center\"><input type=\"submit\" class=\"button\" value=\"Submit\" /></td></tr>" .
                "\t\t\t</table>" .
                "\t\t\t</form>" .   
                "\t\t\t</fieldset>" .
                "<div id=\"ErrorHandler-Container\"></div>";

        
        $tOutput.= '<div id="Info">
                        <b>Ketentuan:</b>
                        <ul>
                            <li>Minimal panjang karakter password adalah 5 karakter.</li>
                            <li>Password adalah CASE-SENSITIVE. Periksa Caps-Lock pada saat setting password baru.</li>
                            <li>Sebaiknya gunakanlah kombinasi huruf, angka dan simbol.<br />(simbol yang diperbolehkan: .,@-_!+=)</li>
                        </ul>
                    </div>';
        
        return $tOutput;
    }

}

